﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Lifang.Entites;
using Lifang.Dao;

namespace Lifang.API.Controllers
{
    [Produces("application/json")]
    [Route("api/PageConfig")]
    public class PageConfigController : BaseController
    {
        [HttpGet("Detail")]
        public JsonResult GetById(int id)
        {
            if (id == 0)
            {
                return Json(new DP_PageConfig());
            }

            var mod = new DapperHelper().SelectModel<DP_PageConfig>(id, new SqlNote("wmg", "查询栏目列表"));
            return Json(mod);
        }

        [HttpGet("Save")]
        public JsonResult SaveOrUpdate(DP_PageConfig mod)
        {
            mod = new DP_PageConfig();
            mod.CreateDateTime = DateTime.Now;
            mod.CreateUserName = "蔡小光";
            mod.CreateUserNo = "02773";
            mod.DataFlag = 1;            
            mod.GroupName = "体育新闻";
            mod.GroupRemark = "体育新闻相关页面";
            mod.HrefTarget = 1;
            mod.ImageUrl = "http://mat1.gtimg.com/sports/index2015/images/LGClogo2.png";
            mod.Url = "http://sports.qq.com/";
            mod.Name = "腾讯体育";
            mod.UpdateDateTime = DateTime.Now;
            mod.UpdateUserName = "蔡小光";
            mod.UpdateUserNo = "02773";
            new PageConfigDao(LoginUserModel).SaveOrUpdateMod(mod);
            return Json(mod);
        }
    }
}